<!DOCTYPE html>

<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">

<title>README - RDoc Documentation</title>

<link type="text/css" media="screen" href="../../../rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../../";
</script>

<script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../js/darkfish.js"></script>


<body class="file">
<nav id="metadata">
  <nav id="home-section" class="section">
  <h3 class="section-header">
    <a href="../../../index.html">Home</a>
    <a href="../../../table_of_contents.html#classes">Classes</a>
    <a href="../../../table_of_contents.html#methods">Methods</a>
  </h3>
</nav>


  <nav id="search-section" class="section project-section" class="initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <h3 class="section-header">
      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">
    </h3>
  </form>

  <ul id="search-results" class="initially-hidden"></ul>
</nav>


  <div id="project-metadata">
    <nav id="fileindex-section" class="section project-section">
  <h3 class="section-header">Pages</h3>

  <ul>
  
    <li class="file"><a href="../../../Gemfile.html">Gemfile</a>
  
    <li class="file"><a href="../../../README_rdoc.html">README</a>
  
    <li class="file"><a href="../../../syc_barcode/Gemfile.html">Gemfile</a>
  
    <li class="file"><a href="../../../syc_barcode/MIT-LICENSE.html">MIT-LICENSE</a>
  
    <li class="file"><a href="../../../syc_barcode/README_rdoc.html">README</a>
  
    <li class="file"><a href="../../../syc_barcode/Rakefile.html">Rakefile</a>
  
    <li class="file"><a href="../../../syc_barcode/test/dummy/README_rdoc.html">README</a>
  
    <li class="file"><a href="../../../syc_barcode/test/dummy/Rakefile.html">Rakefile</a>
  
  </ul>
</nav>

    <nav id="classindex-section" class="section project-section">
  <h3 class="section-header">Class and Module Index</h3>

  <ul class="link-list">
  
    <li><a href="../../../CheckedAttributes.html">CheckedAttributes</a>
  
    <li><a href="../../../CheckedAttributes/ClassMethods.html">CheckedAttributes::ClassMethods</a>
  
    <li><a href="../../../Dummy.html">Dummy</a>
  
    <li><a href="../../../Dummy/Application.html">Dummy::Application</a>
  
    <li><a href="../../../ApplicationController.html">ApplicationController</a>
  
    <li><a href="../../../ApplicationHelper.html">ApplicationHelper</a>
  
    <li><a href="../../../Barcode.html">Barcode</a>
  
    <li><a href="../../../Interleave2of5.html">Interleave2of5</a>
  
    <li><a href="../../../Object.html">Object</a>
  
    <li><a href="../../../SycBarcode.html">SycBarcode</a>
  
    <li><a href="../../../SycBarcodeTest.html">SycBarcodeTest</a>
  
    <li><a href="../../../Visual.html">Visual</a>
  
  </ul>
</nav>

  </div>
</nav>

<div id="documentation" class="description">
  
<h2 id="label-Welcome+to+Rails">Welcome to Rails</h2>

<p>Rails is a web-application framework that includes everything needed to
create database-backed web applications according to the Model-View-Control
pattern.</p>

<p>This pattern splits the view (also called the presentation) into “dumb”
templates that are primarily responsible for inserting pre-built data in
between HTML tags. The model contains the “smart” domain objects (such as
Account, Product, Person, Post) that holds all the business logic and knows
how to persist themselves to a database. The controller handles the
incoming requests (such as Save New Account, Update Product, Show Post) by
manipulating the model and directing data to the view.</p>

<p>In Rails, the model is handled by what’s called an object-relational
mapping layer entitled Active Record. This layer allows you to present the
data from database rows as objects and embellish these data objects with
business logic methods. You can read more about Active Record in <a
href="../../../files/vendor/rails/activerecord/README.html.">files/vendor/rails/activerecord/README.html.</a></p>

<p>The controller and view are handled by the Action Pack, which handles both
layers by its two parts: Action View and Action Controller. These two
layers are bundled in a single package due to their heavy interdependence.
This is unlike the relationship between the Active Record and Action Pack
that is much more separate. Each of these packages can be used
independently outside of Rails. You can read more about Action Pack in <a
href="../../../files/vendor/rails/actionpack/README.html.">files/vendor/rails/actionpack/README.html.</a></p>

<h2 id="label-Getting+Started">Getting Started</h2>
<ol><li>
<p>At the command prompt, create a new Rails application:</p>

<pre>&lt;tt&gt;rails new myapp&lt;/tt&gt; (where &lt;tt&gt;myapp&lt;/tt&gt; is the application name)</pre>
</li><li>
<p>Change directory to <code>myapp</code> and start the web server:</p>

<pre>&lt;tt&gt;cd myapp; rails server&lt;/tt&gt; (run with --help for options)</pre>
</li><li>
<p>Go to <a href="http://localhost:3000">localhost:3000</a>/ and you’ll see:</p>

<pre>&quot;Welcome aboard: You're riding Ruby on Rails!&quot;</pre>
</li><li>
<p>Follow the guidelines to start developing your application. You can find</p>
</li></ol>

<p>the following resources handy:</p>
<ul><li>
<p>The Getting Started Guide: <a
href="http://guides.rubyonrails.org/getting_started.html">guides.rubyonrails.org/getting_started.html</a></p>
</li><li>
<p>Ruby on Rails Tutorial Book: <a
href="http://www.railstutorial.org/">www.railstutorial.org/</a></p>
</li></ul>

<h2 id="label-Debugging+Rails">Debugging Rails</h2>

<p>Sometimes your application goes wrong. Fortunately there are a lot of tools
that will help you debug it and get it back on the rails.</p>

<p>First area to check is the application log files. Have “tail -f” commands
running on the server.log and development.log. Rails will automatically
display debugging and runtime information to these files. Debugging info
will also be shown in the browser on requests from 127.0.0.1.</p>

<p>You can also log your own messages directly into the log file from your
code using the Ruby logger class from inside your controllers. Example:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">WeblogController</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">destroy</span>
    <span class="ruby-ivar">@weblog</span> = <span class="ruby-constant">Weblog</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[:<span class="ruby-identifier">id</span>])
    <span class="ruby-ivar">@weblog</span>.<span class="ruby-identifier">destroy</span>
    <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-node">&quot;#{Time.now} Destroyed Weblog ID ##{@weblog.id}!&quot;</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p>The result will be a message in your log file along the lines of:</p>

<pre>Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!</pre>

<p>More information on how to use the logger is at <a
href="http://www.ruby-doc.org/core/">www.ruby-doc.org/core/</a></p>

<p>Also, Ruby documentation can be found at <a
href="http://www.ruby-lang.org/.">www.ruby-lang.org/.</a> There are several
books available online as well:</p>
<ul><li>
<p>Programming Ruby: <a
href="http://www.ruby-doc.org/docs/ProgrammingRuby/">www.ruby-doc.org/docs/ProgrammingRuby/</a>
(Pickaxe)</p>
</li><li>
<p>Learn to Program: <a
href="http://pine.fm/LearnToProgram/">pine.fm/LearnToProgram/</a> (a
beginners guide)</p>
</li></ul>

<p>These two books will bring you up to speed on the Ruby language and also on
programming in general.</p>

<h2 id="label-Debugger">Debugger</h2>

<p>Debugger support is available through the debugger command when you start
your Mongrel or WEBrick server with –debugger. This means that you can
break out of execution at any point in the code, investigate and change the
model, and then, resume execution! You need to install ruby-debug to run
the server in debugging mode. With gems, use <code>sudo gem install
ruby-debug</code>. Example:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">WeblogController</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">index</span>
    <span class="ruby-ivar">@posts</span> = <span class="ruby-constant">Post</span>.<span class="ruby-identifier">all</span>
    <span class="ruby-identifier">debugger</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p>So the controller will accept the action, run the first line, then present
you with a IRB prompt in the server window. Here you can do things like:</p>

<pre class="ruby"><span class="ruby-operator">&gt;&gt;</span> <span class="ruby-ivar">@posts</span>.<span class="ruby-identifier">inspect</span>
=<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;[#&lt;Post:0x14a6be8
        @attributes={&quot;</span><span class="ruby-identifier">title</span><span class="ruby-string">&quot;=&gt;nil, &quot;</span><span class="ruby-identifier">body</span><span class="ruby-string">&quot;=&gt;nil, &quot;</span><span class="ruby-identifier">id</span><span class="ruby-string">&quot;=&gt;&quot;</span><span class="ruby-value">1</span><span class="ruby-node">&quot;}&gt;,
     #&lt;Post:0x14a6620
        @attributes={&quot;</span><span class="ruby-identifier">title</span><span class="ruby-string">&quot;=&gt;&quot;</span><span class="ruby-constant">Rails</span><span class="ruby-string">&quot;, &quot;</span><span class="ruby-identifier">body</span><span class="ruby-string">&quot;=&gt;&quot;</span><span class="ruby-constant">Only</span> <span class="ruby-identifier">ten</span><span class="ruby-operator">..</span><span class="ruby-string">&quot;, &quot;</span><span class="ruby-identifier">id</span><span class="ruby-string">&quot;=&gt;&quot;</span><span class="ruby-value">2</span><span class="ruby-string">&quot;}&gt;]&quot;</span>
<span class="ruby-operator">&gt;&gt;</span> <span class="ruby-ivar">@posts</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">title</span> = <span class="ruby-string">&quot;hello from a debugger&quot;</span>
=<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;hello from a debugger&quot;</span>
</pre>

<p>…and even better, you can examine how your runtime objects actually work:</p>

<pre class="ruby"><span class="ruby-operator">&gt;&gt;</span> <span class="ruby-identifier">f</span> = <span class="ruby-ivar">@posts</span>.<span class="ruby-identifier">first</span>
=<span class="ruby-operator">&gt;</span> <span class="ruby-comment">#&lt;Post:0x13630c4 @attributes={&quot;title&quot;=&gt;nil, &quot;body&quot;=&gt;nil, &quot;id&quot;=&gt;&quot;1&quot;}&gt;</span>
<span class="ruby-operator">&gt;&gt;</span> <span class="ruby-identifier">f</span>.
<span class="ruby-constant">Display</span> <span class="ruby-identifier">all</span> <span class="ruby-value">152</span> <span class="ruby-identifier">possibilities?</span> (<span class="ruby-identifier">y</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">n</span>)
</pre>

<p>Finally, when you’re ready to resume execution, you can enter “cont”.</p>

<h2 id="label-Console">Console</h2>

<p>The console is a Ruby shell, which allows you to interact with your
application’s domain model. Here you’ll have all parts of the application
configured, just like it is when the application is running. You can
inspect domain models, change values, and save to the database. Starting
the script without arguments will launch it in the development environment.</p>

<p>To start the console, run <code>rails console</code> from the application
directory.</p>

<p>Options:</p>
<ul><li>
<p>Passing the <code>-s, --sandbox</code> argument will rollback any
modifications made to the database.</p>
</li><li>
<p>Passing an environment name as an argument will load the corresponding
environment. Example: <code>rails console production</code>.</p>
</li></ul>

<p>To reload your controllers and models after launching the console run
<code>reload!</code></p>

<p>More information about irb can be found at: <a
href="../../../http:/www.rubycentral.org/pickaxe/irb.html">http://www.rubycentral.org/pickaxe/irb.html</a></p>

<h2 id="label-dbconsole">dbconsole</h2>

<p>You can go to the command line of your database directly through
<code>rails dbconsole</code>. You would be connected to the database with
the credentials defined in database.yml. Starting the script without
arguments will connect you to the development database. Passing an argument
will connect you to a different database, like <code>rails dbconsole
production</code>. Currently works for MySQL, PostgreSQL and SQLite 3.</p>

<h2 id="label-Description+of+Contents">Description of Contents</h2>

<p>The default directory structure of a generated Ruby on Rails application:</p>

<pre>|-- app
|   |-- assets
|       |-- images
|       |-- javascripts
|       `-- stylesheets
|   |-- controllers
|   |-- helpers
|   |-- mailers
|   |-- models
|   `-- views
|       `-- layouts
|-- config
|   |-- environments
|   |-- initializers
|   `-- locales
|-- db
|-- doc
|-- lib
|   `-- tasks
|-- log
|-- public
|-- script
|-- test
|   |-- fixtures
|   |-- functional
|   |-- integration
|   |-- performance
|   `-- unit
|-- tmp
|   |-- cache
|   |-- pids
|   |-- sessions
|   `-- sockets
`-- vendor
    |-- assets
        `-- stylesheets
    `-- plugins</pre>

<p>app</p>

<pre>Holds all the code that's specific to this particular application.</pre>

<p>app/assets</p>

<pre>Contains subdirectories for images, stylesheets, and JavaScript files.</pre>

<p>app/controllers</p>

<pre>Holds controllers that should be named like weblogs_controller.rb for
automated URL mapping. All controllers should descend from
ApplicationController which itself descends from ActionController::Base.</pre>

<p>app/models</p>

<pre>Holds models that should be named like post.rb. Models descend from
ActiveRecord::Base by default.</pre>

<p>app/views</p>

<pre>Holds the template files for the view that should be named like
weblogs/index.html.erb for the WeblogsController#index action. All views use
eRuby syntax by default.</pre>

<p>app/views/layouts</p>

<pre>Holds the template files for layouts to be used with views. This models the
common header/footer method of wrapping views. In your views, define a layout
using the &lt;tt&gt;layout :default&lt;/tt&gt; and create a file named default.html.erb.
Inside default.html.erb, call &lt;% yield %&gt; to render the view using this
layout.</pre>

<p>app/helpers</p>

<pre>Holds view helpers that should be named like weblogs_helper.rb. These are
generated for you automatically when using generators for controllers.
Helpers can be used to wrap functionality for your views into methods.</pre>

<p>config</p>

<pre>Configuration files for the Rails environment, the routing map, the database,
and other dependencies.</pre>

<p>db</p>

<pre>Contains the database schema in schema.rb. db/migrate contains all the
sequence of Migrations for your schema.</pre>

<p>doc</p>

<pre>This directory is where your application documentation will be stored when
generated using &lt;tt&gt;rake doc:app&lt;/tt&gt;</pre>

<p>lib</p>

<pre>Application specific libraries. Basically, any kind of custom code that
doesn't belong under controllers, models, or helpers. This directory is in
the load path.</pre>

<p>public</p>

<pre>The directory available for the web server. Also contains the dispatchers and the
default HTML files. This should be set as the DOCUMENT_ROOT of your web
server.</pre>

<p>script</p>

<pre>Helper scripts for automation and generation.</pre>

<p>test</p>

<pre>Unit and functional tests along with fixtures. When using the rails generate
command, template test files will be generated for you and placed in this
directory.</pre>

<p>vendor</p>

<pre>External libraries that the application depends on. Also includes the plugins
subdirectory. If the app has frozen rails, those gems also go here, under
vendor/rails/. This directory is in the load path.</pre>

</div>



<footer id="validator-badges">
  <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
  <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.2.
  <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>

